﻿package mortal.component.window
{
    import com.mui.controls.*;
    import com.mui.display.*;
    import flash.events.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.mvc.interfaces.*;

    public class ResultBaseWindow extends Window
    {
        protected var _bg:GImageBitmap;
        protected var _typeBg:GImageBitmap;
        protected var _contentBg:ScaleBitmap;
        protected var _resultIcon:GImageBitmap;
        protected var _enterBtn:GLoadingButton;
        public static const notShowResult:int = 0;
        public static const showSuccess:int = 1;
        public static const showFail:int = 2;

        public function ResultBaseWindow(param1:ILayer = null)
        {
            setSize(696, 357);
            super(param1);
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this.configEventListener(MouseEvent.MOUSE_DOWN, onMouseDownHandler);
            this.addBg();
            this.addTypeBg();
            this.addContentBg();
            this.addEnterButton();
            this.setContentBgSize(370, 96);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            if (this._bg)
            {
                this._bg.dispose(param1);
                this._bg = null;
            }
            if (this._typeBg)
            {
                this._typeBg.dispose(param1);
                this._typeBg = null;
            }
            if (this._contentBg)
            {
                this._contentBg.dispose(param1);
                this._contentBg = null;
            }
            if (this._enterBtn)
            {
                this._enterBtn.dispose(param1);
                this._enterBtn = null;
            }
            if (this._resultIcon)
            {
                this._resultIcon.dispose(param1);
                this._resultIcon = null;
            }
            return;
        }// end function

        protected function addBg() : void
        {
            this._bg = UIFactory.gImageBitmap(ImagesConst.ResultWinBg, 0, -57, this, this.createUI);
            return;
        }// end function

        protected function createUI() : void
        {
            return;
        }// end function

        protected function addTypeBg() : void
        {
            this._typeBg = UIFactory.gImageBitmap(ImagesConst.ResultWinTypeBg, 0, 0, this);
            return;
        }// end function

        protected function addEnterButton() : void
        {
            this._enterBtn = UIFactory.gLoadingButton(ResFileConst.ResultWindowBtn, 0, 0, 114, 33, this);
            this._enterBtn.label = "";
            this._enterBtn.configEventListener(MouseEvent.CLICK, this.enterBtnClickHandler);
            return;
        }// end function

        protected function addContentBg() : void
        {
            this._contentBg = UIFactory.bg(0, 0, -1, -1, this, ImagesConst.Forging_GemEmbedBg2);
            return;
        }// end function

        protected function setContentBgSize(param1:int, param2:int) : void
        {
            this._contentBg.width = param1;
            this._contentBg.height = param2;
            return;
        }// end function

        protected function enterBtnClickHandler(event:MouseEvent) : void
        {
            this.hide();
            return;
        }// end function

        override protected function addCloseButton() : void
        {
            return;
        }// end function

        override protected function updateSize() : void
        {
            super.updateSize();
            if (this._typeBg)
            {
                this._typeBg.x = (this.width - 454) * 0.5 - 15;
                this._typeBg.y = 35;
            }
            if (this._contentBg)
            {
                this._contentBg.x = (this.width - this._contentBg.width) * 0.5;
                this._contentBg.y = this._typeBg.y + 42 - 7;
            }
            if (this._enterBtn)
            {
                this._enterBtn.x = (this.width - this._enterBtn.width) * 0.5;
                this._enterBtn.y = this.height - this._enterBtn.height - 84;
            }
            if (this._resultIcon)
            {
                this._resultIcon.x = (this.width - 251) * 0.5 + 7;
                this._resultIcon.y = -40;
            }
            return;
        }// end function

        private function loadResultIconComplete() : void
        {
            if (isDisposed)
            {
                return;
            }
            this._resultIcon.x = (this.width - 251) * 0.5 + 7;
            this._resultIcon.y = -40;
            return;
        }// end function

        public function set resultType(param1:int) : void
        {
            var _loc_2:String = "";
            switch(param1)
            {
                case notShowResult:
                {
                    _loc_2 = "";
                    break;
                }
                case showSuccess:
                {
                    _loc_2 = ImagesConst.ResultWinSuccess;
                    break;
                }
                case showFail:
                {
                    _loc_2 = ImagesConst.ResultWinFail;
                    break;
                }
                default:
                {
                    break;
                }
            }
            if (this._resultIcon == null)
            {
                this._resultIcon = UIFactory.gImageBitmap("", 0, 0, this);
            }
            this._resultIcon.onLoadCompl = this.loadResultIconComplete;
            this._resultIcon.imgUrl = _loc_2;
            return;
        }// end function

    }
}
